<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>{$webTitle} - {:config('web_webname')}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" type="text/css" href="//cdn.istt.cn/cdn/ver/1.0/web/app.css"/>
    <link rel="stylesheet" type="text/css" href="//cdn.istt.cn/cdn/ver/1.0/css/style.css"/>
    <style type="text/css">
        .w400 {
            max-width: 400px;
        }
    </style>
</head>
<body class="o-y bg-bai dk">
<div id="ajaxshow"></div>
<div class="bg-qing dk m0 pt8 pb8 t-c"><h2>修改密码</h2></div>
<div class="container w400 pt8 pb8 t-c">
    <div class="mt5">
        <div class="list p3"><input id="outpass" type="password" placeholder="请输入旧登陆密码" class="form no f4"></div>
        <div class="list p3"><input  id="password" type="password" placeholder="请输入新的登陆密码" class="form no f4" id="newpass"></div>
        <div class="list p3"><input id="repass" type="password" placeholder="请再输入一次新密码" class="form no f4"></div>
    </div>
    <button class="btn btn-qing btn-lg btn-block mt9 autoenter" id="button">确 定</button>
    <div class="mt7 t-c"><a class="lan" href="{:url('index/find')}">忘记旧密码请点我找回</a></div>
    <div class="mt12"><p class="f0 hui">Copyright &copy; 2020 {:config('web_webname')}</p></div>
</div>
<script type="text/javascript" src="/Static/config/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="//cdn.istt.cn/cdn/inc/js/jquery.pjax.min.js"></script>
<script type="text/javascript" src="//cdn.istt.cn/cdn/ver/1.0/web/layer.min.js"></script>
<script src="/Static/config/js/gt.js"></script>
<script src="/Static/config/js/main.js"></script>
<script src="/Static/config/js/app.js"></script>
<script>
	var handler = function (captchaObj) {
            captchaObj.onReady(function () {
            }).onSuccess(function () {
                var outpass, password, repass;
                outpass = $('#outpass').val();
				password = $('#password').val();
				repass = $('#repass').val();
				var result = captchaObj.getValidate();
				var result_data = {
					geetest_challenge: result.geetest_challenge,
					geetest_validate: result.geetest_validate,
					geetest_seccode: result.geetest_seccode,
					outpass: outpass,
					password: password,
					repass: repass,
				};
				var load = x.loading('', true);
				app.ajax("{:url('UserAjax/newpwd')}", result_data, function (data) {
					layer.close(load);
					if (data.code === 0) {
						if (result) {
							x.loading('修改密码成功,请重新登陆');
							setTimeout(function () {
								window.location.href = "{:url('Index/login')}";
							}, 1000)
						} else {
							x.btn('请先完成验证');
						}
					} else {
						x.btn(data.message);
						captchaObj.reset();
					}
				}, '', false);
            });
            $('#button').click(function () {
                var outpass, password, repass;
                outpass = $('#outpass').val();
				password = $('#password').val();
				repass = $('#repass').val();
                if (!outpass) {
                    $('#outpass').focus();
                    x.msg("请输入旧登陆密码");
                    return false;
                }
                if (!password) {
                    $('#password').focus();
                    x.msg("请输入新的登陆密码");
                    return false;
                }
                if (!repass) {
                    $('#repass').focus();
                    x.msg("请再输入一次新密码");
                    return false;
                }
				if(password != repass){
					$('#repass').focus();
					$('#password').focus();
					x.msg("两次密码输入不一致");
					return false;
				}
                captchaObj.verify();
            }
            );
        };
        app.ajax("{:url('Common/Geetest_captcha')}?t=" + (new Date()).getTime(), undefined, function (data) {
            initGeetest({
                gt: data.gt,
                challenge: data.challenge,
                offline: !data.success, // 表示用户后台检测极验服务器是否宕机
                new_captcha: data.new_captcha, // 用于宕机时表示是新验证码的宕机
                product: "bind", // 产品形式，包括：float，popup
                width: "190px",
                https: false
            }, handler);
        });
</script>
</body>
</html>